package logic

import (
	"context"
	"house_srv/models"

	"house_srv/house"
	"house_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHouseShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseShowLogic {
	return &HouseShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 房源详情
func (l *HouseShowLogic) HouseShow(in *house.HouseShowRequest) (*house.HouseShowResponse, error) {
	// todo: add your logic here and delete this line
	var houses models.House
	models.DB.Debug().Where("id=?", in.Id).Find(&houses)

	return &house.HouseShowResponse{
		Title:    houses.Title,
		Image:    houses.Image,
		Address:  houses.Address,
		UserId:   houses.UserId,
		MinPrice: float32(houses.MinPrice),
		MaxPrice: float32(houses.MaxPrice),
		Price:    float32(houses.Price),
		Size:     houses.Size,
	}, nil
}
